import request from '@neu/biz-core/utils/request'
const baseUrl = 'dcam/api/w/fixed/inventory/plans'
import { list as dList } from '@neu/dcam-ui/api/dictionary'

export const list = (params) => {
  return request({
    url: baseUrl,
    params,
    method: 'get'
  })
}

export const page = (params) => {
  return request({
    url: baseUrl + '/p',
    params,
    method: 'get'
  })
}

export const create = (data) => {
  return request({
    url: baseUrl,
    data,
    method: 'post'
  })
}

export const remove = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'delete'
  })
}

export const detail = (id) => {
  return request({
    url: baseUrl + '/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: baseUrl + '/' + id,
    data,
    method: 'put'
  })
}

export const status = () => {
  return dList({ s_type: 'inventoryPlanStatus' })
}

export const issue = (id) => {
  return request({
    url: baseUrl + '/issue/' + id,
    method: 'put'
  })
}

export const synchronousData = (ids, rule) => {
  return request({
    url: baseUrl + '/syndata/' + ids + '/rule/' + rule,
    method: 'post'
  })
}

export const donePlan = (id) => {
  return request({
    url: baseUrl + '/doneplan/' + id,
    method: 'put'
  })
}

export const createdList = (params) => {
  return request({
    url: baseUrl + '/status/created',
    params,
    method: 'get'
  })
}
